<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
  <table lay-filter="layerTable" lay-skin="line">
    <thead>
      <tr>
        <th class="xutd" lay-data="{field:'xutdId', width:60,fixed:'left'}">序号</th>
        <th lay-data="{field:'roleName'}">角色名称</th>
        <th lay-data="{field:'roleCode'}">标识CODE</th>
        <th lay-data="{field:'roleModular'}">角色模块</th>
        <th lay-data="{field:'status'}">状态</th>
        <th lay-data="{field:'createTime'}">创建时间</th>
        <th lay-data="{field:'setting', width:150}">操作</th>
      </tr>
    </thead>
    <tbody>
      <c:forEach items="${pager.result}" var="item" varStatus="index">
	      <tr>
	        <td>${(index.index+1)+pager.pageParameter.pageSize*(pager.pageParameter.current-1) }</td>
	        <td>${item.roleName}</td>
	        <td>${item.roleShrioCode }</td>
            <td>
                <c:if test="${item.roleModuleType == 'sysman'}">系统运维</c:if>
                <c:if test="${item.roleModuleType == 'enterprise'}">企业角色</c:if>
                <c:if test="${item.roleModuleType == 'security'}">公安角色</c:if>
            </td>
	        <td>
	        	<c:if test="${item.status == 'normal' }">正常</c:if>
	        	<c:if test="${item.status == 'locked' }">正常</c:if>
	        </td>
	        <td>${item.createTime}</td>
            <td>
                <shiro:hasPermission name="sysman:SYSTEM_ROLE_MAN:edit">
                    <button class="layui-btn layui-btn-small" data-id="${item.roleCode}" type="button" onclick="toEdit(this);">
                        <i class="layui-icon" title="编辑">&#xe642;</i>
                    </button>
                </shiro:hasPermission>
                <shiro:hasPermission name="sysman:SYSTEM_ROLE_MAN:delete">
                    <button class="layui-btn layui-btn-small layui-btn-danger" data-id="${item.roleCode}" type="button" onclick="toDel(this)">
                        <i class="layui-icon" title="删除">&#xe640;</i>
                    </button>
                </shiro:hasPermission>
            </td>
	      </tr>
      </c:forEach>
    </tbody>
  </table>
<div id="layer-page"></div>
<input type="hidden" id="currentPage" value="${pager.pageParameter.current}" />
<input type="hidden" id="pageSize" value="${pager.pageParameter.pageSize}" />
<script type="text/javascript">
    layui.use(['table', 'laypage'], function(){
        var table = layui.table;
        //转换静态表格
        table.init('layerTable', {
            height: $(window).height() - 220, //设置高度,
            limit:${pager.pageParameter.pageSize}
        });
        var laypage = layui.laypage;
        //执行一个laypage实例
        laypage.render({
            elem: 'layer-page' //注意，这里的 test1 是 ID，不用加 # 号
            ,limits:[20,40,60,80,100,200]
            ,limit:${pager.pageParameter.pageSize}
            ,curr:${pager.pageParameter.current}
            ,count: ${pager.pageParameter.totalCount} //数据总数，从服务端得到
            ,layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
            ,jump: function(obj, first){
                console.log(obj.curr);
                console.log(obj.limit);
                //首次不执行
                if(!first){
                    baseSearchQueryLayer(obj.curr,obj.limit);
                    //转换静态表格
                }
            }
        });

        window.onresize = function() {
            //转换静态表格
            table.init('layerTable', {
                height: $(window).height() - 220, //设置高度,
                limit:${pager.pageParameter.pageSize}
            });
        }
    });
      function toDel(obj){
          baseSelDel(obj);
      }

      function toEdit(obj){
          toBaseSelEdit(obj,false,933,530,true);
      }
  </script>